#ifndef CAN_H
#define CAN_H

#include <stdint.h>
#include "gd32f30x_can.h"

#define HEM_CAN_TX_INTERRUPT_ENABLE 1
typedef struct CAN_ID_FORMAT_TAG
{
    uint32_t id; /*!<identifier */
    uint8_t ide; /*!< 0:standard format frame identifier;!0:extended identifier,  */
} CAN_ID_FORMAT_T;

typedef struct CAN_Tx_FIFO
{
    uint32_t id; 
    uint8_t buf[8];
    uint8_t len;
    uint8_t ide; 
    uint8_t valid;
}CAN_Tx_FIFO_t;
extern can_receive_message_struct receive_message_bootloader;


extern void CAN_init(void);

extern int DRV_CANBUS_Send(uint32_t id, uint8_t ide, uint8_t *data, uint8_t length); 

extern uint32_t ul_can_rx_cnt;
extern uint32_t ul_can_rx_cnt_last;
extern uint16_t us_set_can_baudrate;

void Can_Data_Store_Fifo(uint32_t id, uint8_t ide, uint8_t *data, uint8_t length);
void Can_Tx_Fifo(void);
#endif
